package com.chima.dao;

import java.util.List;

import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.chima.domain.Performance;
import com.chima.domain.PerformancePostcount;

public class PerformanceCountDao extends HibernateDaoSupport{
	public void save(PerformancePostcount performancePostcount) {
		this.getHibernateTemplate().save(performancePostcount);
	}
	public List<PerformancePostcount> findByDateAndDepart(String date, int Depart) {
		String hql="select * from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+Depart+"' ";
		Session session   =this.getSession();
		List<PerformancePostcount> p = session.createSQLQuery(hql).addEntity(PerformancePostcount.class).list();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxJinjizhongyao(String date,int depart) {
		String hql="select max(jinjizhongyao) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxJinjibuzhongyao(String date,int depart) {
		String hql="select max(jinjibuzhongyao) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxbuJinjizhongyao(String date,int depart) {
		String hql="select max(bujinjizhongyao) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxbuJinjibuzhongyao(String date,int depart) {
		String hql="select max(bujinjibuzhongyao) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxtaidu(String date,int depart) {
		String hql="select max(taidu) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxability(String date,int depart) {
		String hql="select max(ability) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}public Double findMaxcircum(String date,int depart) {
		String hql="select max(circum) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxmanager(String date,int depart) {
		String hql="select max(manager) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
	public Double findMaxteshu(String date,int depart) {
		String hql="select max(teshu) from t_performancepostcount t where Month(t.date) = Month('"+date+"') and YEAR(t.date) = YEAR('"+date+"') and t.departID='"+depart+"'";
		Session session   =this.getSession();
		Double  p =(Double) session.createSQLQuery(hql).uniqueResult();
		super.releaseSession(session);
		return p;
	}
}
